package com.itbaizhan.service;

import java.util.function.Function;

public class WeatherService implements Function<WeatherService.Request,WeatherService.Response> {

    /**
     * 应用
     * @param request the function argument
     * @return
     */
    @Override
    public Response apply(Request request) {
        if (request.city.contains("杭州")){
            return new Response("晴转多云,气温32摄氏度");
        }else if(request.city.contains("北京")){
            return new Response("天气冷,气温17摄氏度");
        }else {
            return new Response("暂时无法查询天气情况");
        }
    }

    /**
     * 输入
     * @param city
     */
    public record Request(String city){}

    /**
     * 输出
     * @param city
     */
    public record Response(String city){}



}
